import { leaseDetail } from '@/api/lease'
import { saleDetail } from '@/api/sale'

const state = {
  leaseDetail: {},
  saleDetail: {}
}

const mutations = {
  SAVE_LEASE: (state, detail) => {
    state.leaseDetail = detail
  },
  SAVE_SALE: (state, detail) => {
    state.saleDetail = detail
  }
}

const actions = {
  async getLeaseDatail({ commit }, id) {
    var leaseRes = await leaseDetail(id)
    commit('SAVE_LEASE', leaseRes.data)
  },
  async getSaleDatail({ commit }, id) {
    var saleRes = await saleDetail(id)
    commit('SAVE_SALE', saleRes.data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
